- content_for :head do
  = javascript_include_tag  'tiny_mce/tiny_mce.js'
  %script{:type => "text/javascript"}
    = "tinyMCE.init({"
    = '   mode : "textareas",'
    = '   theme : "advanced",'
    = '   plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",'
    = '   theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,image,|,forecolor,backcolor",'
    = '   theme_advanced_buttons2 : "",'
    = '   theme_advanced_toolbar_location : "top",'
    = '   theme_advanced_toolbar_align : "left",'
    = '   template_external_list_url : "/javascripts/tiny_mce/lists/template_list.js",'
    = '   external_link_list_url : "/javascripts/tiny_mce/lists/link_list.js",'
    = '   external_image_list_url : "/javascripts/tiny_mce/lists/image_list.js",'
    = '   media_external_list_url : "/javascripts/tiny_mce/lists/media_list.js",'
    = "});"
%h1.page_title Gallery
%table.new_gallery
  - form_for @gallery, :method => :put do |form| 
    %tr
      %td.field_title Name:
      %td.field= form.text_field :name
      %td.error= error_message_on :gallery, :name
    %tr
      %td.field_title Description:
      %td.field= form.text_area :description
      %td.error= error_message_on :gallery, :text
    %tr
      %td.field_title Pricing:
      %td.field
        %select{:name => "gallery[price_list_id]"}
          %option{:value => ''} not purchasable
          - @price_lists.each do |price_list|
            %option{:value => price_list.id, :selected => ('selected' if price_list == @gallery.price_list)}= price_list.name
      %td.error
        = error_message_on :gallery, :price_list
    %tr
      %td.field_title Templete:
      %td.field
        %select{:name => "gallery[gallery_template_id]"}
          - @gallery_templates.each do |gallery_template|
            %option{:value => gallery_template.id, :selected => ('selected' if gallery_template == @gallery.gallery_template)}= gallery_template.name
      %td.error
        = error_message_on :gallery, :gallery_templete
    %tr
      %td.field_title Pages:
      %td.field= select_tag("gallery[page_ids][]", options_for_select(@pages.collect { |cat| [cat.title, cat.id] }, @gallery.pages.collect { |cat| cat.id}), {:multiple=>true, :size=>6})
      %td.error= error_message_on :gallery, :page
    %tr
      %td.field_title Invisible?
      %td.field
        = check_box_tag("gallery[invisible]", 1)
        Won't show up in search results or anywhere else
      %td.error= error_message_on :gallery, :invisible
    %tr
      %td.field_title For Proofing?
      %td.field
        = check_box_tag("gallery[for_proofing]", 1)
        For clients to proof photos
      %td.error= error_message_on :gallery, :for_proofing
    %tr
      %td.field_title Clients:
      %td.field
        = select_tag("gallery[user_ids][]", options_for_select(@users.collect { |cat| [cat.login, cat.id] }, @gallery.users.collect { |cat| cat.id}), {:multiple=>true, :size=>6})
      %td.error
    %tr
      %td.field_title Thumbnail:
      %td.field
        %div.gallery_thumbnails
          - @thumbnails.each do |photo|
            %table.gallery_thumbnail
              %tr
                %td.photo
                  %a{:href => photo_url(photo), :title => (photo.caption ? photo.caption : photo.filename), :alt => (photo.caption ? photo.caption : photo.filename)}
                    %img.photo_thumb{:src => photo.public_filename(:thumb), :title => (photo.caption ? photo.caption : photo.filename), :alt => (photo.caption ? photo.caption : photo.filename)}
              %tr
                %td.check_box= radio_button_tag("gallery[photo_id]", photo.id)
    %tr
      %td
      %td.submit= submit_tag 'create'